﻿using HC.View;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EMRView;
using EMRView.Extensions.HCAttribute;

namespace EMRView.Extensions.Command.StandardCommand.File
{
    [Command(CommandType.文件, "NewFile", "新建文件")]
    public class NewFileCommand : BaseCommand
    {
        public override Icon CommandIcon
        {
            get
            {
                return Properties.HCResource.新建;
            }
        }
        public override object Execute(HCEmrView _view, bool showDefaultUI = false, params object[] para)
        {
            if (para == null)
            {
                _view.FileName = "";
                _view.Clear();
                _view.IsChanged = false;
                return null;
            }
            if (para != null && para.Length == 1 && (para[0] != null && para[0]?.ToString().ToUpper() == "TRUE"))
            {
                if (MessageBox.Show("是否新建文档！" + System.Environment.NewLine + "新建文档将清空当前文档，是否继续?", "新建提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    _view.FileName = "";
                    _view.Clear();
                    _view.IsChanged = false;
                }
            }
            else
            {
                _view.FileName = "";
                _view.Clear();
                _view.IsChanged = false;
            }
            return null;
        }

        public override void InitControl(object control)
        {
        }
    }
}
